#include "general.h"
-#include "gtkadjustment.h"
#include "gtkdebug.h"
#include "gtklabel.h"
#include "gtkscale.h"
GtkWidget *gtk_exe_prefix;
GtkWidget *gtk_data_prefix;
GtkWidget *gsettings_schema_dir;
- GtkWidget *hidpi_spin;
- GtkWidget *touchscreen_switch;
- GtkAdjustment *scale_adjustment;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorGeneral, gtk_inspector_general, GTK_TYPE_BOX)
set_path_label (gen->priv->gsettings_schema_dir, "GSETTINGS_SCHEMA_DIR");
}
-static void
-update_touchscreen (GtkSwitch *sw, GParamSpec *pspec, GtkInspectorGeneral *gen)
-{
- GtkDebugFlag flags;
-
- flags = gtk_get_debug_flags ();
-
- if (gtk_switch_get_active (sw))
- flags |= GTK_DEBUG_TOUCHSCREEN;
- else
- flags &= ~GTK_DEBUG_TOUCHSCREEN;
-
- gtk_set_debug_flags (flags);
-}
-
-#if defined (GDK_WINDOWING_X11) && defined (HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE)
-static void
-scale_changed (GtkAdjustment *adjustment, GtkInspectorGeneral *gen)
-{
- GdkDisplay *display;
- gint scale;
-
- scale = gtk_adjustment_get_value (adjustment);
- display = gtk_widget_get_display (GTK_WIDGET (gen));
- gdk_x11_display_set_window_scale (display, scale);
-}
-#endif
-
-static void
-init_settings (GtkInspectorGeneral *gen)
-{
-#if defined (GDK_WINDOWING_X11) && defined (HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE)
- GdkScreen *screen;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (gen));
- if (GDK_IS_X11_SCREEN (screen))
- {
- gdouble scale;
-
- scale = gdk_screen_get_monitor_scale_factor (screen, 0);
- gtk_adjustment_set_value (gen->priv->scale_adjustment, scale);
- g_signal_connect (gen->priv->scale_adjustment, "value-changed",
- G_CALLBACK (scale_changed), gen);
- }
- else
-#endif
- {
- gtk_adjustment_set_value (gen->priv->scale_adjustment, 1);
- gtk_widget_set_sensitive (gen->priv->hidpi_spin, FALSE);
- gtk_widget_set_tooltip_text (gen->priv->hidpi_spin,
- _("Backend does not support window scaling"));
- }
-
- gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0);
- g_signal_connect (gen->priv->touchscreen_switch, "notify::active",
- G_CALLBACK (update_touchscreen), gen);
-
- if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0)
- {
- /* hardcoded, nothing we can do */
- gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), TRUE);
- gtk_widget_set_sensitive (gen->priv->touchscreen_switch, FALSE);
- gtk_widget_set_tooltip_text (gen->priv->touchscreen_switch, _("Setting is hardcoded by GTK_TEST_TOUCHSCREEN"));
- }
-}
-
static void
gtk_inspector_general_init (GtkInspectorGeneral *gen)
{
gtk_widget_init_template (GTK_WIDGET (gen));
init_version (gen);
init_env (gen);
- init_settings (gen);
}
static void
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_exe_prefix);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_data_prefix);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gsettings_schema_dir);
- gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, hidpi_spin);
- gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, scale_adjustment);
- gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, touchscreen_switch);
}
// vim: set et sw=2 ts=2:
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30">
- <object class="GtkAdjustment" id="scale_adjustment">
- <property name="lower">1</property>
- <property name="upper">2</property>
- <property name="step-increment">1</property>
- <property name="page-increment">1</property>
- </object>
<template class="GtkInspectorGeneral" parent="GtkBox">
<property name="orientation">vertical</property>
<property name="margin">60</property>
</child>
</object>
</child>
- <child>
- <object class="GtkFrame" id="settings_frame">
- <property name="visible">True</property>
- <property name="halign">center</property>
- <child>
- <object class="GtkListBox">
- <property name="visible">True</property>
- <property name="selection-mode">none</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="margin">10</property>
- <property name="spacing">40</property>
- <child>
- <object class="GtkLabel" id="hidpi_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Window scaling</property>
- <property name="halign">start</property>
- <property name="valign">baseline</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
- <child>
- <object class="GtkSpinButton" id="hidpi_spin">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">baseline</property>
- <property name="adjustment">scale_adjustment</property>
- <property name="snap-to-ticks">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="margin">10</property>
- <property name="spacing">40</property>
- <child>
- <object class="GtkLabel" id="touchscreen_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Simulate touchscreen</property>
- <property name="halign">start</property>
- <property name="valign">baseline</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="touchscreen_switch">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">baseline</property>
- </object>
- <packing>
- <property name="expand">True</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
</template>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widget name="gtk_exe_prefix_label"/>
<widget name="gtk_data_prefix_label"/>
<widget name="gsettings_schema_dir_label"/>
- <widget name="touchscreen_label"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<widgets>
<widget name="version_frame"/>
<widget name="env_frame"/>
- <widget name="settings_frame"/>
</widgets>
</object>
</interface>
#include "visual.h"
+#include "gtkadjustment.h"
+#include "gtkbox.h"
#include "gtkcomboboxtext.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtkswitch.h"
#include "gtkwindow.h"
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
+
struct _GtkInspectorVisualPrivate
{
+ GtkWidget *visual_box;
+ GtkWidget *theme_combo;
+ GtkWidget *dark_switch;
+ GtkWidget *icon_combo;
GtkWidget *direction_combo;
+ GtkWidget *hidpi_spin;
+ GtkAdjustment *scale_adjustment;
+
+ GtkWidget *debug_box;
GtkWidget *updates_switch;
GtkWidget *baselines_switch;
GtkWidget *pixelcache_switch;
+ GtkWidget *touchscreen_switch;
- GtkWidget *theme_combo;
- GtkWidget *dark_switch;
- GtkWidget *icon_combo;
+ GtkAdjustment *focus_adjustment;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorVisual, gtk_inspector_visual, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorVisual, gtk_inspector_visual, GTK_TYPE_SCROLLED_WINDOW)
static void
fix_direction_recurse (GtkWidget *widget,
g_free (theme);
}
+#if defined (GDK_WINDOWING_X11) && defined (HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE)
+static void
+scale_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
+{
+ GdkDisplay *display;
+ gint scale;
+
+ scale = gtk_adjustment_get_value (adjustment);
+ display = gtk_widget_get_display (GTK_WIDGET (vis));
+ gdk_x11_display_set_window_scale (display, scale);
+}
+#endif
+
+static void
+init_scale (GtkInspectorVisual *vis)
+{
+#if defined (GDK_WINDOWING_X11) && defined (HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE)
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (vis));
+ if (GDK_IS_X11_SCREEN (screen))
+ {
+ gdouble scale;
+
+ scale = gdk_screen_get_monitor_scale_factor (screen, 0);
+ gtk_adjustment_set_value (vis->priv->scale_adjustment, scale);
+ g_signal_connect (vis->priv->scale_adjustment, "value-changed",
+ G_CALLBACK (scale_changed), vis);
+ }
+ else
+#endif
+ {
+ gtk_adjustment_set_value (vis->priv->scale_adjustment, 1);
+ gtk_widget_set_sensitive (vis->priv->hidpi_spin, FALSE);
+ gtk_widget_set_tooltip_text (vis->priv->hidpi_spin,
+ _("Backend does not support window scaling"));
+ }
+}
+
+static void
+update_touchscreen (GtkSwitch *sw)
+{
+ GtkDebugFlag flags;
+
+ flags = gtk_get_debug_flags ();
+
+ if (gtk_switch_get_active (sw))
+ flags |= GTK_DEBUG_TOUCHSCREEN;
+ else
+ flags &= ~GTK_DEBUG_TOUCHSCREEN;
+
+ gtk_set_debug_flags (flags);
+}
+
+static void
+init_touchscreen (GtkInspectorVisual *vis)
+{
+ gtk_switch_set_active (GTK_SWITCH (vis->priv->touchscreen_switch), (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0);
+ g_signal_connect (vis->priv->touchscreen_switch, "notify::active",
+ G_CALLBACK (update_touchscreen), NULL);
+
+ if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0)
+ {
+ /* hardcoded, nothing we can do */
+ gtk_switch_set_active (GTK_SWITCH (vis->priv->touchscreen_switch), TRUE);
+ gtk_widget_set_sensitive (vis->priv->touchscreen_switch, FALSE);
+ gtk_widget_set_tooltip_text (vis->priv->touchscreen_switch, _("Setting is hardcoded by GTK_TEST_TOUCHSCREEN"));
+ }
+}
+
+static gboolean
+keynav_failed (GtkWidget *widget, GtkDirectionType direction, GtkInspectorVisual *vis)
+{
+ GtkWidget *next;
+ gdouble value, lower, upper, page;
+
+ if (direction == GTK_DIR_DOWN &&
+ widget == vis->priv->visual_box)
+ next = vis->priv->debug_box;
+ else if (direction == GTK_DIR_UP &&
+ widget == vis->priv->debug_box)
+ next = vis->priv->visual_box;
+ else
+ next = NULL;
+
+ if (next)
+ {
+ gtk_widget_child_focus (next, direction);
+ return TRUE;
+ }
+
+ value = gtk_adjustment_get_value (vis->priv->focus_adjustment);
+ lower = gtk_adjustment_get_lower (vis->priv->focus_adjustment);
+ upper = gtk_adjustment_get_upper (vis->priv->focus_adjustment);
+ page = gtk_adjustment_get_page_size (vis->priv->focus_adjustment);
+
+ if (direction == GTK_DIR_UP && value > lower)
+ {
+ gtk_adjustment_set_value (vis->priv->focus_adjustment, lower);
+ return TRUE;
+ }
+ else if (direction == GTK_DIR_DOWN && value < upper - page)
+ {
+ gtk_adjustment_set_value (vis->priv->focus_adjustment, upper - page);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
gtk_inspector_visual_init (GtkInspectorVisual *vis)
{
init_theme (vis);
init_dark (vis);
init_icons (vis);
+ init_scale (vis);
+ init_touchscreen (vis);
+}
+
+static void
+gtk_inspector_visual_constructed (GObject *object)
+{
+ GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
+
+ G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->constructed (object);
+
+ vis->priv->focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (vis));
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (vis))),
+ vis->priv->focus_adjustment);
+
+ g_signal_connect (vis->priv->visual_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
+ g_signal_connect (vis->priv->debug_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
}
static void
gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = gtk_inspector_visual_constructed;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/visual.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, updates_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, dark_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, theme_combo);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, icon_combo);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, hidpi_spin);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, scale_adjustment);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, touchscreen_switch);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, visual_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, debug_box);
gtk_widget_class_bind_template_callback (widget_class, updates_activate);
gtk_widget_class_bind_template_callback (widget_class, direction_changed);
gtk_widget_class_bind_template_callback (widget_class, pixelcache_activate);
gtk_widget_class_bind_template_callback (widget_class, theme_changed);
gtk_widget_class_bind_template_callback (widget_class, icons_changed);
-
}
// vim: set et sw=2 ts=2:
#ifndef _GTK_INSPECTOR_VISUAL_H_
#define _GTK_INSPECTOR_VISUAL_H_
-#include <gtk/gtkbox.h>
+#include <gtk/gtkscrolledwindow.h>
#define GTK_TYPE_INSPECTOR_VISUAL (gtk_inspector_visual_get_type())
#define GTK_INSPECTOR_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_VISUAL, GtkInspectorVisual))
typedef struct _GtkInspectorVisual
{
- GtkBox parent;
+ GtkScrolledWindow parent;
GtkInspectorVisualPrivate *priv;
} GtkInspectorVisual;
typedef struct _GtkInspectorVisualClass
{
- GtkBoxClass parent;
+ GtkScrolledWindowClass parent;
} GtkInspectorVisualClass;
G_BEGIN_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30">
- <template class="GtkInspectorVisual" parent="GtkBox">
+ <object class="GtkAdjustment" id="scale_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">2</property>
+ <property name="step-increment">1</property>
+ <property name="page-increment">1</property>
+ </object>
+ <template class="GtkInspectorVisual" parent="GtkScrolledWindow">
+ <property name="hscrollbar-policy">never</property>
+ <property name="vscrollbar-policy">automatic</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="margin">60</property>
<property name="spacing">10</property>
<property name="visible">True</property>
<property name="halign">center</property>
<child>
- <object class="GtkListBox">
+ <object class="GtkListBox" id="visual_box">
<property name="visible">True</property>
<property name="selection-mode">none</property>
+ <style>
+ <class name="view"/>
+ </style>
<child>
<object class="GtkBox">
<property name="visible">True</property>
</child>
</object>
</child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin">10</property>
+ <property name="spacing">40</property>
+ <child>
+ <object class="GtkLabel" id="hidpi_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Window scaling</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="hidpi_spin">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="adjustment">scale_adjustment</property>
+ <property name="snap-to-ticks">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
<property name="visible">True</property>
<property name="halign">center</property>
<child>
- <object class="GtkListBox">
+ <object class="GtkListBox" id="debug_box">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<child>
</child>
</object>
</child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin">10</property>
+ <property name="spacing">40</property>
+ <child>
+ <object class="GtkLabel" id="touchscreen_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Simulate touchscreen</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="touchscreen_switch">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
+ </object>
+ </child>
</template>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widget name="dark_label"/>
<widget name="icon_label"/>
<widget name="direction_label"/>
+ <widget name="hidpi_label"/>
<widget name="updates_label"/>
<widget name="baselines_label"/>
<widget name="pixelcache_label"/>
+ <widget name="touchscreen_label"/>
</widgets>
</object>
<object class="GtkSizeGroup">